package DynamicProgramming;

public class 一和零 {
    public int findMaxForm(String[] strs, int m, int n) {
        int[][] dp = new int[m + 1][n + 1];
        for (String str : strs) {
            int x = 0, y = 0;
            for (char c : str.toCharArray()) {
                if (c == '0') x++;
                else y++;
            }
            for (int j = m; j >= x; j--) {
                for (int k = n; k >= y; k--) {
                    dp[j][k] = Math.max(dp[j][k], dp[j - x][k - y] + 1);
                }
            }
        }
        return dp[m][n];
    }
}
